*------------------------------------------------------------------------------*
* 	Table 2: Baseline Experiment		 	   *
*------------------------------------------------------------------------------*
{
cd "$data"
use ExperimentalData_Applications_All, clear

*Panel A. Loan Requests

*Number of Assigned loan requests
tab app_female
*Number of submitted loan requests (Non-Attriter) 
*Number of submitted loan requests (Attriter) 
tab app_female attriter
*Attrition Rate
sum attriter if app_female==0
sum attriter if app_female==1

*Standard Errors clustered at the bank-branch level (in parenthesis)

local off_female off_female
local regionbankfe d_region_bank_fe1-d_region_bank_fe61
local loanamount credit_asked_ammount_cat1-credit_asked_ammount_cat8   
local weekfe d_week1-d_week22
local salience treat
local indivcovariates app_age_below_29 app_age_29_38 app_married app_wage_600_1200 app_wage_above_1200 app_self_employed app_bank_client d_miss_app_married d_miss_app_self_employed
local execcovariates off_higher_educ off_exp_6_or_less off_exp_7_to_12 off_age_18_28 off_age_29_48 pro_male_portfolio

foreach outcome of varlist attriter  {
            regress `outcome' app_female, cluster(region_bank_fe)
			sum `outcome' if app_female==1
			local mean_female = r(mean)
			sum `outcome' if app_female==0
			local mean_male = r(mean)
			outreg2 app_female using "${tables}/Table2_PanelA_Unadjusted_Mean_Diff_cse.xls", keep(app_female) addstat("mean_female", `mean_female', "mean_male", `mean_male') adec(3) excel `append' bdec(3) sdec(3) stats(coef se) auto(3) alpha(.01, .05, .10) symbol(***,**,*) br
            regress `outcome' app_female `off_female' `regionbankfe' `loanamount' `salience' , cluster(region_bank_fe)
			sum `outcome' if app_female==1
			local mean_female = r(mean)
			sum `outcome' if app_female==0
			local mean_male = r(mean)
			outreg2 app_female using "${tables}/Table2_PanelA_Model1_cse.xls", keep(app_female) addstat("mean_female", `mean_female', "mean_male", `mean_male') adec(3) excel `append' bdec(3) sdec(3) stats(coef se) auto(3) alpha(.01, .05, .10) symbol(***,**,*) br
            local append "append"            
            regress `outcome' app_female `off_female' `regionbankfe' `loanamount' `salience' `indivcovariates' `execcovariates', cluster(region_bank_fe)
			sum `outcome' if app_female==1
			local mean_female = r(mean)
			sum `outcome' if app_female==0
			local mean_male = r(mean)
			outreg2 app_female using "${tables}/Table2_PanelA_Model2_cse.xls", keep(app_female) addstat("mean_female", `mean_female', "mean_male", `mean_male') adec(3) excel `append' bdec(3) sdec(3) stats(coef se) auto(3) alpha(.01, .05, .10) symbol(***,**,*) br
            local append "append"            
			}           

			
*Bootstrapped Standard Errors (in brackets)

sort aux
			
local off_female off_female
local regionbankfe d_region_bank_fe1-d_region_bank_fe61
local loanamount credit_asked_ammount_cat1-credit_asked_ammount_cat8   
local weekfe d_week1-d_week22
local salience treat
local indivcovariates app_age_below_29 app_age_29_38 app_married app_wage_600_1200 app_wage_above_1200 app_self_employed app_bank_client d_miss_app_married d_miss_app_self_employed
local execcovariates off_higher_educ off_exp_6_or_less off_exp_7_to_12 off_age_18_28 off_age_29_48 pro_male_portfolio


foreach outcome of varlist attriter  {
            regress `outcome' app_female, vce(boot, rep(3000) seed(1010101))
			sum `outcome' if app_female==1
			local mean_female = r(mean)
			sum `outcome' if app_female==0
			local mean_male = r(mean)
			outreg2 app_female using "${tables}/Table2_PanelA_Unadjusted_Mean_Diff_bse.xls", keep(app_female) addstat("mean_female", `mean_female', "mean_male", `mean_male') adec(3) excel `append' bdec(3) sdec(3) stats(coef se) auto(3) alpha(.01, .05, .10) symbol(***,**,*) br
            regress `outcome' app_female `off_female' `regionbankfe' `loanamount' `salience', vce(boot, rep(3000) seed(1010101))
			sum `outcome' if app_female==1
			local mean_female = r(mean)
			sum `outcome' if app_female==0
			local mean_male = r(mean)
			outreg2 app_female using "${tables}/Table2_PanelA_Model1_bse.xls", keep(app_female) addstat("mean_female", `mean_female', "mean_male", `mean_male') adec(3) excel `append' bdec(3) sdec(3) stats(coef se) auto(3) alpha(.01, .05, .10) symbol(***,**,*) br
            local append "append"            
            regress `outcome' app_female `off_female' `regionbankfe' `loanamount' `salience' `indivcovariates' `execcovariates', vce(boot, rep(3000) seed(1010101))
			sum `outcome' if app_female==1
			local mean_female = r(mean)
			sum `outcome' if app_female==0
			local mean_male = r(mean)
			outreg2 app_female using "${tables}/Table2_PanelA_Model2_bse.xls", keep(app_female) addstat("mean_female", `mean_female', "mean_male", `mean_male') adec(3) excel `append' bdec(3) sdec(3) stats(coef se) auto(3) alpha(.01, .05, .10) symbol(***,**,*) br
            local append "append"            
			}   			
			
*Panel B: Loan Applicants

cd "$data"
use ExperimentalData_Applicants, clear

*Number of Borrowers
tab app_female

*Robust standard errors are shown in parentheses

local regionfe d_region1-d_region11
local indivcovariates app_age_below_29 app_age_29_38 app_married app_wage_600_1200 app_wage_above_1200 app_self_employed app_bank_client d_miss_app_married d_miss_app_self_employed

foreach outcome of varlist tester_attriter_4 tester_attriter_3 tester_attriter_2 tester_attriter_1 tester_attriter_0  {
            regress `outcome' app_female, r
			sum `outcome' if app_female==1
			local mean_female = r(mean)
			sum `outcome' if app_female==0
			local mean_male = r(mean)
			outreg2 app_female using "${tables}/Table2_PanelB_Unadjusted_Mean_Diff.xls", keep(app_female) addstat("mean_female", `mean_female', "mean_male", `mean_male') adec(3) excel `append' bdec(3) sdec(3) stats(coef se) auto(3) alpha(.01, .05, .10) symbol(***,**,*) br
            regress `outcome' app_female `regionfe', r
			sum `outcome' if app_female==1
			local mean_female = r(mean)
			sum `outcome' if app_female==0
			local mean_male = r(mean)
			outreg2 app_female using "${tables}/Table2_PanelB_Model1.xls", keep(app_female) addstat("mean_female", `mean_female', "mean_male", `mean_male') adec(3) excel `append' bdec(3) sdec(3) stats(coef se) auto(3) alpha(.01, .05, .10) symbol(***,**,*) br
            local append "append"            
            regress `outcome' app_female `regionfe' `indivcovariates', r
			sum `outcome' if app_female==1
			local mean_female = r(mean)
			sum `outcome' if app_female==0
			local mean_male = r(mean)
			outreg2 app_female using "${tables}/Table2_PanelB_Model2.xls", keep(app_female) addstat("mean_female", `mean_female', "mean_male", `mean_male') adec(3) excel `append' bdec(3) sdec(3) stats(coef se) auto(3) alpha(.01, .05, .10) symbol(***,**,*) br
            local append "append"            
			}           

}
        

